<?
	Screen()->inc_css('chrome.css');
	js_include_shared('smototype.js', 'Smuoi.js', 'scriptaculous.js?load=effects'); 
?><!--

	var Login = {
		
		counter:{
			secs:0,
			exp:290,
			start:function(){
				Login.counter.intrvl = setInterval(function(){
					if(!Login.counter.secs) $('expr').appear();
					Login.counter.secs = Login.counter.secs + 10;
					$('secs').innerHTML = nicetime((Login.counter.exp - Login.counter.secs)*1000);
					if(Login.counter.secs >= Login.counter.exp){
						clearInterval(Login.counter.intrvl);
						Login.disable();
						$('xprd').appear()
					}
				}, 10000);
			}
		},
		
		disable:function(ie){
			if(ie) return $('loginWindow').style.zIndex = $('loginBack').style.zIndex -1;
			$('loginbtn').disabled = true;
			$('loginWindow').fade({to:0.2, afterFinish:function(){
				$('loginWindow').style.opacity = 1
				$('loginWindow').style.zIndex = $('loginBack').style.zIndex -1;
			}});
			$('loginBack').appear({to:0.9});
		},
		
		hash:function(){
			var n = $('un').value.trim();
			if(!n) return $('un').focus()
			var p = $('up').value.trim();
			if(!p) return $('up').focus()
			$('loginbtn').style.color = 'green';
			setTimeout(function(){
				$('loginbtn').hide();
				$('lwait').show();
			}, 200);
			var s = '<?=sn()->mkSalt()?>';
			//alert(hex_sha1(p));
			//alert(hex_sha1(hex_sha1(p)+s));
			Smajax.login(n, hex_sha1(hex_sha1(p)+''+s), 1);
		},
		
		done:function(){
			window.location.href = window.location.pathname;
		},
		
		run:function(){
			$('loginWait').hide();
			if(Prototype.Browser.IE){
				Login.disable(1);
				$('ieRebuff').show();
				return;	
			}		
			$('loginWait').hide();
			$('loginBack').appear({to:0.6});
			$('loginWindow').appear();
			Login.counter.start();
			$('un').focus();
			$('loginbtn').disabled = false;
		}
	}
	

	window.queue(Login.run); 
	
//-->